<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Room Chatting</title>
	<script src="/socket.io/socket.io.js"></script>
	<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
	<script>
		window.onload = function() {
			var room = prompt('방 이름을 입력하세요.', '');
			var socket = io.connect();
			
			// add socket event handler
			socket.emit('join', room);
			socket.on('message', function(data) {
				$('<p>' + data + '</p>').appendTo('body');
			});
			// add document event handler

			document.getElementById('emit').onclick = function() {
				socket.emit('message', 'socket.io room message');
			};
		};
	</script>
</head>
<body>
	<button id='emit'>EMIT</button>
</body>
</html>